import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import path from "path";
// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  resolve: {
    // Vite路径别名配置
    alias: {
      "@": path.resolve("./src"),
    },
  },
  // 设置跨域，前后端分离
  server: {
    proxy: {
      "/api": {
        target: "http://192.168.0.117:8081/backend", //指向地址
        changeOrigin: true, //是否支持跨域，是
        ws: true, //用于支持websocket
        rewrite: (path) => path.replace(/^\/api/, ""), //将所有含/api路径的，去掉/api,替换成空，传给服务器
      },
    },
  },
});
